package dacp.etl.kafka.steam;

import java.util.List;

import com.google.common.base.Objects;
import com.google.common.collect.Lists;

public class Pos {
	int inx;
	int beforeSortInx;

	Pos next;
	List<Processor> ps = Lists.newArrayList();

	public Pos(int inx, int beforeSortInx) {
		this.inx = inx;
		this.beforeSortInx = beforeSortInx;
	}

	boolean hasnext() {
		return next != null;
	}

	void addProcessor(Processor p) {
		ps.add(p);
	}

	public String trans(String ori) {
		String rst = ori;
		for (Processor pps : ps) {
			rst = pps.process(rst);
		}
		return rst;
	}

	@Override
	public String toString() {

		return Objects.toStringHelper(this).add("inx", inx).add("binx", beforeSortInx).add("processors", ps)
				.add("next", next).toString();
	}
}
